import { BaseView } from '../../rxjs/cc3/BaseView';
import { _decorator, Node, v2, v3 } from 'cc';
import { BindNodeTouch } from '../../rxjs/cc3/BindNode';
const { ccclass, property } = _decorator;

const _v20 = v2();
const _v30 = v3();

@ccclass('touchFloat')
export class touchFloat extends BaseView {

    useObserves() {
        return [
            BindNodeTouch(this.node).subscribe(_ => {
                // this.log('@', _);
                switch (_.type) {
                    case Node.EventType.TOUCH_MOVE:
                        _.touch.getUIDelta(_v20);

                        this.node.getPosition(_v30);
                        _v30.x += _v20.x;
                        _v30.y += _v20.y;
                        this.node.setPosition(_v30);
                        break;
                }
            }),
        ];
    }
}


